Address Activity
The AddressActivity
prompts the user to enter their address information, including street, city, province, country, and zip code.
Inputs
The AddressActivity
expects the following properties:
- Title (
string
): A heading that indicates the purpose of the address input (e.g., "Enter Address"). - Description (
string
): Additional instructions for the user (e.g., "Please provide your complete address."). - ButtonCancelText (
string
): Text displayed on the cancel button (e.g., "Cancel"). - ButtonOKText (
string
): Text displayed on the confirmation button (e.g., "Submit").
Example Code
addressActivity: async (data: AddressActivityOptions) => {
console.log("AddressActivity from agent:", data);
await delay(300);
return new Promise<{ action: WorkflowActivityUserAction; result: any }>((resolve) => {
RootNavigation.navigate("WorkflowActivityScreen", {
type: "address",
data,
onConfirm: (result: any) => {
console.log("AddressActivity result:", result);
resolve({
action: WorkflowActivityUserAction.OK,
result,
});
},
onReject: () => {
console.log("AddressActivity result:", "Rejected");
resolve({
action: WorkflowActivityUserAction.Cancel,
result: "",
});
},
});
});
};
Handling and Layout
When the user navigates to the WorkflowActivityScreen for an Address Activity, the layout includes:
-
Title: A heading that indicates the purpose of the address input (e.g., "Enter Address").
-
Description: Additional instructions guiding the user’s input.
-
Address Information Input:
- Street Address: A text input for the street name and number.
- City: A text input for the city.
- Province/State: A text input for the state or province.
- Country: A text input for the country.
- Zip Code: A numeric input for the postal code.
-
Action Buttons:
- Cancel Button: Allows the user to cancel their input, returning a
Cancel
action. - Confirm Button: Submits the user’s input, returning an
OK
action with the entered details.
- Cancel Button: Allows the user to cancel their input, returning a
Output
The output for an Address Activity depends on the user's interaction:
- If the user confirms, the resolved result will look like this:
{
action: WorkflowActivityUserAction.OK,
result: {
streetAddress: "123 Main St",
city: "City",
province: "State",
country: "Country",
zipCode: "12345"
}
}
- If the user cancels, the resolved result will look like this:
{
action: WorkflowActivityUserAction.Cancel,
result: ""
}